﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;
using Common.Framework.GlobalEntities;

namespace ProductsGUI.Core
{
    public class ClientCacheManager : Common.Framework.Cache.CacheManager
    {
        private static ClientCacheManager m_Instance;
        public static ClientCacheManager Instance
        {
            get
            {
                if (m_Instance == null)
                {
                    m_Instance = new ClientCacheManager();
                }

                return m_Instance;
            }
        }

        #region

        private Dictionary<string, LookupTableDTO> m_lookupTables = new Dictionary<string, LookupTableDTO>();

        public LookupTableDTO GetLookupTable(string tableName)
        {
            LookupTableDTO res;
            if (m_lookupTables.ContainsKey(tableName))
            {
                return m_lookupTables[tableName];
            }

            // get lookup from server
            res = ServiceManager.Instance.GlobalServices.GetLookupTable(tableName);
            if (res != null)
            {
                res.Createdate = DateTime.Now;
                m_lookupTables.Add(res.TableName, res);
            }

            return res;
        }

        #endregion

    }
}